<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
      <el-form-item label="标准代码" prop="itemBzCode">
        <el-input
          v-model="queryParams.itemBzCode"
          placeholder="请输入标准代码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="标准名称" prop="itemBzName">
        <el-input
          v-model="queryParams.itemBzName"
          placeholder="请输入标准名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="规格型号" prop="spec">
        <el-input
          v-model="queryParams.spec"
          placeholder="请输入规格型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="法兰外径" prop="flwjD">
        <el-input
          v-model="queryParams.flwjD"
          placeholder="请输入法兰外径"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="法兰内径" prop="flnj">
        <el-input
          v-model="queryParams.flnj"
          placeholder="请输入法兰内径"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料识别码" prop="itemIdentifyCode">
        <el-input
          v-model="queryParams.itemIdentifyCode"
          placeholder="请输入物料识别码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="生成标记" prop="scFlag">
      <el-select   @keyup.enter.native="handleQuery"   v-model="queryParams.scFlag" clearable placeholder="请选择生成标记">
        <el-option
          v-for="dict in dict.type.sc_flag"
          :key="dict.value"
          :label="dict.label"
          :value="dict.value"
        ></el-option>
      </el-select>
      </el-form-item>
     <!-- <el-form-item label="法兰内径系列I" prop="flnj1">
        <el-input
          v-model="queryParams.flnj1"
          placeholder="请输入法兰内径系列I"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="法兰内径系列Ⅱ" prop="flnj2">
        <el-input
          v-model="queryParams.flnj2"
          placeholder="请输入法兰内径系列Ⅱ"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['base:itembzinfo:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['base:itembzinfo:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          :disabled="multiple"
          @click="handleAddItemInfoGz"
          v-hasPermi="['base:itembzinfo:addItemInfoGz']"
        >生成物料规则</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['base:itembzinfo:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          @click="handleDeleteAll"
          v-hasPermi="['base:itembzinfo:removeAll']"
        >全部删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
        >导入</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['base:itembzinfo:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :max-height="tableHeight" :data="itembzinfoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
<!--      <el-table-column label="公司代码" fixed="left" align="center" prop="tenantId" />-->
<!--      <el-table-column label="公司名称" fixed="left" align="center" prop="tenantName">-->
<!--        <template>-->
<!--          <div>泰康</div>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="标准名称" fixed="left"  align="center" prop="itemBzName" />
      <el-table-column label="物料名称" fixed="left" align="center" prop="itemName" />
      <el-table-column label="标准代码" fixed="left" align="center" prop="itemBzCode" width="120"/>
      <el-table-column label="标准简码" fixed="left" align="center" prop="itemBzSimCode"/>
      <el-table-column label="规格型号" fixed="left"  show-overflow-tooltip width="140" align="center" prop="spec" />
      <el-table-column label="公称压力PN " align="center" prop="gcylPn" />
      <el-table-column label="公称通径DN " align="center" prop="gctjDn" />
      <el-table-column label="法兰外径D" align="center" prop="flwjD" />
      <el-table-column label="法兰内径 " align="center" prop="flnj" />
      <el-table-column label="法兰厚度C" align="center" prop="flhdC" />
      <el-table-column label="法兰密封面尺寸d" align="center" prop="flmfmccD" />
      <el-table-column label="法兰台高f" align="center" prop="fltgF" />
      <el-table-column label="法兰孔中心圆直径K" align="center" prop="flkzxyzjK" />
      <el-table-column label="法兰孔径L" align="center" prop="flkjL" />
      <el-table-column label="法兰孔数n" align="center" prop="flksN" />
      <el-table-column label="理论重量 " align="center" prop="llzl" />
      <el-table-column label="下料重量 " align="center" prop="xlzl" />
      <el-table-column label="计算重量 " align="center" prop="jszl" />
      <el-table-column label="法兰螺栓规格" align="center" prop="fllsSpec" />
      <el-table-column label="法兰理论重量(kg)平面FF系列I" align="center" prop="flllzlpm1Ff" />
      <el-table-column label="法兰理论重量(kg)平面FF系列Ⅱ" align="center" prop="flllzlpm2Ff" />
      <el-table-column label="法兰理论重量(kg)突面RF系列I" align="center" prop="flllzltm1Rf" />
      <el-table-column label="法兰理论重量(kg)突面RF系列IⅡ" align="center" prop="flllzltm2Rf" />
      <el-table-column label="法兰盖理论重量平面FF" align="center" prop="flgllzlpmFf" />
      <el-table-column label="法兰盖理论重量突面RF" align="center" prop="flgllzlpmRf" />
      <el-table-column label="法兰内径系列I" align="center" prop="flnj1" />
      <el-table-column label="法兰内径系列Ⅱ" align="center" prop="flnj2" />
      <el-table-column label="钢管外径 " align="center" prop="ggwj" />
      <el-table-column label="钢管外径系列I" align="center" prop="ggwj1" />
      <el-table-column label="钢管外径系列Ⅱ" align="center" prop="ggwj2" />
      <el-table-column label="法兰盖厚度C" align="center" prop="flghdC" />
      <el-table-column label="物料识别码" width="220" show-overflow-tooltip align="center" prop="itemIdentifyCode" />
      <el-table-column label="核定标记" align="center" prop="hdFlag" />
      <el-table-column label="生成标记" align="center" prop="scFlag">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sc_flag" :value="scope.row.scFlag"/>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" width="160" align="center" prop="createTime" />
      <el-table-column label="创建者" align="center" prop="createBy" />
      <el-table-column label="更新时间" width="160" align="center" prop="updateTime" />
      <el-table-column label="更新者" align="center" prop="updateBy" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" width="130" fixed="right"  align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['base:itembzinfo:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['base:itembzinfo:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改物料标准明细对话框 -->
    <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
     <!--   <el-form-item label="公司代码" prop="tenantId">
          <el-input v-model="form.tenantId" placeholder="请输入公司代码" />
        </el-form-item>-->
        <el-row>
          <el-col :span="12">
            <el-form-item label="标准代码" prop="itemBzCode">
              <el-input v-model="form.itemBzCode" placeholder="请输入标准代码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="标准名称" prop="itemBzName">
              <el-input v-model="form.itemBzName" placeholder="请输入标准名称" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="规格型号" prop="spec">
              <el-input v-model="form.spec" placeholder="请输入规格型号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="公称压力PN " prop="gctjDn">
              <el-input v-model="form.gcylPn" placeholder="请输入公称压力PN " />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="公称通径DN " prop="gctjDn">
              <el-input v-model="form.gctjDn" placeholder="请输入公称通径DN " />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料名称" prop="ggwj">
              <el-input v-model="form.itemName" placeholder="请输入物料名称" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="钢管外径" prop="ggwj">
              <el-input v-model="form.ggwj" placeholder="请输入钢管外径" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="法兰内径" prop="flnj">
              <el-input v-model="form.flnj" placeholder="请输入法兰内径" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="法兰外径D" prop="flwjD">
              <el-input v-model="form.flwjD" placeholder="请输入法兰外径D" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="理论重量" prop="llzl">
              <el-input v-model="form.llzl" placeholder="请输入理论重量" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="计算重量" prop="jszl">
              <el-input v-model="form.jszl" placeholder="请输入计算重量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="下料重量" prop="xlzl">
              <el-input v-model="form.xlzl" placeholder="请输入下料重量" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="法兰孔中心圆直径K" prop="flkzxyzjK">
              <el-input v-model="form.flkzxyzjK" placeholder="请输入法兰孔中心圆直径K" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="法兰孔径L" prop="flkjL">
              <el-input v-model="form.flkjL" placeholder="请输入法兰孔径L" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="法兰孔数n" prop="flksN">
              <el-input v-model="form.flksN" placeholder="请输入法兰孔数n" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="法兰螺栓规格" prop="fllsSpec">
              <el-input v-model="form.fllsSpec" placeholder="请输入法兰螺栓规格" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="法兰厚度C" prop="flhdC">
              <el-input v-model="form.flhdC" placeholder="请输入法兰厚度C" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="法兰密封面尺寸d" prop="flmfmccD">
              <el-input v-model="form.flmfmccD" placeholder="请输入法兰密封面尺寸d" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="法兰台高f" prop="fltgF">
              <el-input v-model="form.fltgF" placeholder="请输入法兰台高f" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="法兰理论重量(kg)平面FF系列I" prop="flllzlpm1Ff">
              <el-input v-model="form.flllzlpm1Ff" placeholder="请输入法兰理论重量(kg)平面FF系列I" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="法兰理论重量(kg)平面FF系列Ⅱ" prop="flllzlpm2Ff">
              <el-input v-model="form.flllzlpm2Ff" placeholder="请输入法兰理论重量(kg)平面FF系列Ⅱ" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="法兰理论重量(kg)突面RF系列I" prop="flllzltm1Rf">
              <el-input v-model="form.flllzltm1Rf" placeholder="请输入法兰理论重量(kg)突面RF系列I" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="法兰理论重量(kg)突面RF系列IⅡ" prop="flllzltm2Rf">
              <el-input v-model="form.flllzltm2Rf" placeholder="请输入法兰理论重量(kg)突面RF系列IⅡ" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="法兰盖厚度C" prop="flghdC">
              <el-input v-model="form.flghdC" placeholder="请输入法兰盖厚度C" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="法兰盖理论重量平面FF" prop="flgllzlpmFf">
              <el-input v-model="form.flgllzlpmFf" placeholder="请输入法兰盖理论重量平面FF" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="法兰盖理论重量突面RF" prop="flgllzlpmRf">
              <el-input v-model="form.flgllzlpmRf" placeholder="请输入法兰盖理论重量突面RF" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="钢管外径系列I" prop="ggwj1">
              <el-input v-model="form.ggwj1" placeholder="请输入钢管外径系列I" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="钢管外径系列Ⅱ" prop="ggwj2">
              <el-input v-model="form.ggwj2" placeholder="请输入钢管外径系列Ⅱ" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="法兰内径系列I" prop="flnj1">
              <el-input v-model="form.flnj1" placeholder="请输入法兰内径系列I" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="法兰内径系列Ⅱ" prop="flnj2">
              <el-input v-model="form.flnj2" placeholder="请输入法兰内径系列Ⅱ" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="核定标记" prop="hdFlag">
              <el-input v-model="form.hdFlag" placeholder="请输入核定标记" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="生成标记" prop="scFlag">
              <el-select style="width:100%" v-model="form.scFlag" placeholder="请选择生成标记">
                <el-option
                  v-for="dict in dict.type.sc_flag"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
        <el-col :span="12">
          <el-form-item label="备注" prop="remark">
            <el-input v-model="form.remark" placeholder="请输入备注" />
          </el-form-item>
        </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>


    <!-- 物料导入对话框 -->
    <el-dialog :close-on-click-modal="false" :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!--  <div class="el-upload__tip" slot="tip">
              <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
            </div>-->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listItembzinfo, getItembzinfo, delItembzinfo,delAllItembzinfo, addItembzinfo, updateItembzinfo,addItemInfoGz} from "@/api/base/itembzinfo";
import {getToken} from "@/utils/auth";

export default {
  name: "Itembzinfo",
  dicts: ['sc_flag'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 物料标准明细表格数据
      itembzinfoList: [],
      // 表格的高度
      tableHeight: document.documentElement.scrollHeight - 245 + "px",
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        itemBzCode: null,
        itemBzName: null,
        spec: null,
        flwjD: null,
        flnj1: null,
        flnj2: null,
        itemIdentifyCode:null,
        scFlag:null
      },
      // 表单参数
      form: {},

      // 物料导入参数
      upload: {
        // 是否显示弹出层（物料导入）
        open: false,
        // 弹出层标题（物料导入）
        title: "导入标准物料",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/base/itembzinfo/importData"
      },
      // 表单校验
      rules: {
        itemBzCode: [
          { required: true, message: "标准代码不能为空", trigger: "blur" }
        ],
        itemBzName: [
          { required: true, message: "标准名称不能为空", trigger: "blur" }
        ],
        spec: [
          { required: true, message: "规格型号不能为空", trigger: "blur" }
        ],
        flwjD: [
          { required: true, message: " 法兰外径D外径不能为空", trigger: "blur" }
        ],
        flhdC: [
          { required: true, message: "法兰厚度C不能为空", trigger: "blur" }
        ],
        flmfmccD: [
          { required: true, message: "法兰密封面尺寸d不能为空", trigger: "blur" }
        ],
        fltgF: [
          { required: true, message: "法兰台高f不能为空", trigger: "blur" }
        ],
        flnj: [
          { required: true, message: "法兰内径不能为空", trigger: "blur" }
        ],
        xlzl: [
          { required: true, message: "下料重量不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询物料标准明细列表 */
    getList() {
      this.loading = true;
      listItembzinfo(this.queryParams).then(response => {
        this.itembzinfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        tenantId: null,
        itemBzCode: null,
        itemBzName: null,
        spec: null,
        gctjDn: null,
        ggwj1: null,
        ggwj2: null,
        flwjD: null,
        flkzxyzjK: null,
        flkjL: null,
        flksN: null,
        fllsSpec: null,
        flhdC: null,
        flmfmccD: null,
        fltgF: null,
        flnj1: null,
        flnj2: null,
        flllzlpm1Ff: null,
        flllzlpm2Ff: null,
        flllzltm1Rf: null,
        flllzltm2Rf: null,
        flghdC: null,
        flgllzlpmFf: null,
        flgllzlpmRf: null,
        hdFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加物料标准明细";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getItembzinfo(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改物料标准明细";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateItembzinfo(this.form).then(response => {
              this.$modal.alertSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addItembzinfo(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    handleAddItemInfoGz(row){
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认生成物料规则？').then(function() {
        return addItemInfoGz(ids);
      }).then(() => {
        this.getList();
        this.$modal.alertSuccess("生成物料规则成功");
      }).catch(() => {});
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除物料标准明细编号为"' + ids + '"的数据项？').then(function() {
        return delItembzinfo(ids);
      }).then(() => {
        this.getList();
        this.$modal.alertSuccess("删除成功");
      }).catch(() => {});
    },
    handleDeleteAll(){
      this.$modal.confirm('是否确认全部删除数据？').then(function() {
        return delAllItembzinfo();
      }).then(() => {
        this.getList();
        this.$modal.alertSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('base/itembzinfo/export', {
        ...this.queryParams
      }, `itembzinfo_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "物料导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('base/itembzinfo/importTemplate', {
      }, `itembzinfo${new Date().getTime()}.xlsx`)
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    }
  }
};
</script>
